package snooker.scoreboard;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;

public class BallBitmapHandler {

	private Resources r;
	
	public BallBitmapHandler(Resources r) {
		this.r = r;
	}
	
	public void setEnabled(ImageView v, boolean enabled, Ball ball) {
		v.setEnabled(enabled);
		if (enabled) {
			v.setImageBitmap(getEnabledBitmap(ball));
		} else {
			v.setImageBitmap(getDisabledBitmap(ball));
		}
	}
	
	private Bitmap getDisabledBitmap(Ball ball) {
		Bitmap originalBitmap = BitmapFactory.decodeResource(r, ball.getResourceId());
		Bitmap myBitmap = Bitmap.createBitmap(originalBitmap.getWidth(), 
				originalBitmap.getHeight(), Bitmap.Config.ARGB_8888);
		return myBitmap;
	}
	
	private Bitmap getEnabledBitmap(Ball ball) {
		Bitmap originalBitmap = BitmapFactory.decodeResource(r, ball.getResourceId());
		return originalBitmap;
	}
	
}
